<template>
  <el-card shadow="hover" class="package-card">
    <div class="package-header">
      <h4>{{ pkg.title }}</h4>
      <el-tag type="warning" v-if="pkg.tag">{{ pkg.tag }}</el-tag>
    </div>
    
    <div class="package-content">
      <div class="package-detail">
        <span class="label">有效期:</span>
        <span class="value">{{ pkg.day }}天</span>
      </div>
      
      <div class="package-detail">
        <span class="label">原价:</span>
        <span class="value price">{{ pkg.origin_price }}元</span>
      </div>
      
      <div class="price-tiers">
        <div class="tier-title">价格梯度:</div>
        <el-descriptions :column="1" border size="small">
          <el-descriptions-item v-for="(price, range) in pkg.price" :key="range" :label="range + '台'">
            {{ price }}元/台
          </el-descriptions-item>
        </el-descriptions>
      </div>
      
      <div class="package-tags">
        <el-tag v-if="pkg.activate_name" type="success" size="small">{{ pkg.activate_name }}</el-tag>
        <el-tag v-if="pkg.renew_display" type="info" size="small">支持续费</el-tag>
      </div>
    </div>
    
    <div class="package-actions">
      <el-button type="primary" size="small" @click="$emit('edit')">编辑</el-button>
      <el-button type="danger" size="small" @click="$emit('remove')">删除</el-button>
    </div>
  </el-card>
</template>

<script setup lang="ts">
defineProps({
  pkg: {
    type: Object,
    required: true
  }
})

defineEmits(['edit', 'remove'])
</script>

<style lang="scss" scoped>
.package-card {
  margin-bottom: 20px;
  height: 100%;
  
  .package-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    
    h4 {
      margin: 0;
    }
  }
  
  .package-content {
    .package-detail {
      margin-bottom: 10px;
      display: flex;
      justify-content: space-between;
      
      .label {
        color: #999;
      }
      
      .price {
        text-decoration: line-through;
        color: #999;
      }
    }
    
    .price-tiers {
      margin: 15px 0;
      
      .tier-title {
        margin-bottom: 8px;
        font-weight: bold;
      }
    }
    
    .package-tags {
      margin: 10px 0;
      display: flex;
      gap: 5px;
    }
  }
  
  .package-actions {
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }
}
</style> 